package edu.zust.zw.shop;

import java.util.ArrayList;
import java.util.List;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.MediaType;
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.databind.ObjectMapper;

@Configuration
public class JSONConfig {

	@Bean
	public MappingJackson2HttpMessageConverter jackconConfig() {
		System.out.println("ddddd------------------------------------------------");
		MappingJackson2HttpMessageConverter jackson = new MappingJackson2HttpMessageConverter();
		jackson.setPrefixJson(false);
		List<MediaType> MediaTypes = new ArrayList<>();
		MediaTypes.add(MediaType.APPLICATION_JSON);
		jackson.setSupportedMediaTypes(MediaTypes);
		ObjectMapper objectMapper = new ObjectMapper();
		objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
		jackson.setObjectMapper(objectMapper);
		return jackson;
	}
}
